#include <iostream>
using namespace std;

int partition(int arr[],int low,int high) {
    int mid = arr[low];
    while (low < high) {
        while (low<high && mid <= arr[high])
            high--;
        arr[low] = arr[high];
        while (low < high && mid >= arr[low])
            low++;
        arr[high] = arr[low];
    }
    arr[low] = mid;
    return low;
}

void quickSort(int arr[],int low , int high) {
    if (low < high) {
        int mid = partition(arr,low,high);
        quickSort(arr,low,mid-1);
        quickSort(arr,mid+1,high);
    }
}

int main() {
    std::cout << "Hello, World!" << std::endl;
    int A[8] = {0,5,5,3,5,7,5,5};
    int A2[8] = {0,5,5,3,5,1,5,7};

    // quickSort(A,0,8);
    // quickSort(A2,0,8);
    int cntA = 0;
    int cntA2 = 0;
    int out = A[0];
    for (int i = 0; i < 8; ++i) {
        for (int j = 0;j < 8;++j)
            if (A[i] == A[j]) {
                cntA ++;
            }
        if (cntA > 4) {
            out = A[i];
            break;
        }
        // 这里
        cntA = 0;
    }
    if (cntA > 4)
        cout<<out<<endl<<cntA;
    int out2 = A2[0];
    for (int i = 0; i < 8; ++i) {
        for (int j = 0;j < 8;++j)
            if (A2[i] == A2[j]) {
                cntA2 ++;
            }
        if (cntA2 > 4) {
            out2 = A2[i];
            break;
        }
        cntA2 = 0;
    }
    if(cntA2>4){
    cout<<out2<<endl;
    cout<<cntA2;
}
    else
        cout<<endl<<"-1";
    return 0;
}
